Dont show the GtkWindow when removing it from a parent and becomming a toplevel
authorTristan Van Berkom <tristan.van.berkom@gmail.com>
Mon, 3 Jan 2011 15:55:04 +0000 (00:55 +0900)
committerTristan Van Berkom <tristan.van.berkom@gmail.com>
Thu, 6 Jan 2011 05:39:41 +0000 (14:39 +0900)
Showing the window causes it to try to grab focus, this causes problems
when embedded toplevels run through dispose cycles.

gtk/gtkwindow.c
tests/testtoplevelembed.c

index 09879cecad798978bd1fdc24fd5899ac20363356..e69c0185bd285bdcfb0e343bdfcab8e353c38ef4 100644 (file)
@@ -9236,14 +9236,16 @@ _gtk_window_set_is_toplevel (GtkWindow *window,
 
   if (is_toplevel)
     {
-      gboolean was_visible = gtk_widget_get_visible (widget);
-
       /* Pass through regular pathways of an embedded toplevel
        * to go through unmapping and hiding the widget before
        * becomming a toplevel again.
+       *
+       * We remain hidden after becomming toplevel in order to
+       * avoid problems during an embedded toplevel's dispose cycle
+       * (When a toplevel window is shown it tries to grab focus again,
+       * this causes problems while disposing).
        */
-      if (was_visible)
-       gtk_widget_hide (widget);
+      gtk_widget_hide (widget);
 
       /* Save the toplevel this widget was previously anchored into before
        * propagating a hierarchy-changed. 
@@ -9266,13 +9268,6 @@ _gtk_window_set_is_toplevel (GtkWindow *window,
       _gtk_widget_propagate_hierarchy_changed (widget, toplevel);
 
       toplevel_list = g_slist_prepend (toplevel_list, window);
-
-      /* If an embedded toplevel gets removed from the hierarchy
-       * and is still in a visible state, we need to show it again
-       * so it will be realized as a real toplevel again.
-       */
-      if (was_visible)
-       gtk_widget_show (widget);
     }
   else
     {
index 12a79b2a42ad43cff83ff65dbfdba72547511dea..c698252acb213b7d877c2f209586b2cf4ef4ef05 100644 (file)
@@ -9,6 +9,7 @@ remove_notebook_page (GtkWidget *button,
                      GtkWidget *toplevel)
 {
   gtk_container_remove (GTK_CONTAINER (notebook), toplevel);
+  gtk_widget_show (toplevel);
 }
 
 GtkWidget *